package com.learn.SingleTon;

/**
 * 登录 - 子类 - 单例
 */
public class ChildRegister extends Register{

    /**
     * 由于子类必须允许父类以构造方法的方式创建子类，所以必须式public类型的，
     * 这就说明了可以通过new的方式来创建
     * 但是前提必须是登记过
     */
    public ChildRegister() {}

    public static void main(String[] args) {
        ChildRegister register1 = (ChildRegister)getInstance("com.learn.SingleTon.ChildRegister");
        ChildRegister register2 = (ChildRegister)getInstance("com.learn.SingleTon.ChildRegister");
        ChildRegister register3 = new ChildRegister();

        //返回true代表单例实现
        System.out.println(register1 == register2);

        //但是不能使用new,因为前提约束是需要在父类中登记的才是单例
        System.out.println(register1 == register3);
    }
}
